#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
using namespace std;
int main()
{

    cout << "第二: 字符串的赋值 assign();" << endl;
    cout << "1.感觉就像是append不过是抹除-覆盖\n";
    cout << "string e;\nchar f[10]=\"123456\"\ne.assign(f);\ne+=' ';\ncout<<e<<endl<<endl;\n";
    string e;
    char f[10] = "123456";
    e.assign(f);
    e += ' ';
    cout << e << endl
         << endl;

    cout << "2.string区间 赋值都类似吧\n";
    cout << "e.assign(f,3,3);\ne+=' ';\ncout<<e<<endl<<endl;\ne.assign(f,3);\ncout<<e<<endl;\n";
    e.assign(f, 3, 3);
    e += ' ';
    cout << e << endl;
    e.assign(f, 3);
    cout << e << endl
         << endl;

    cout << "3.某字符串char型 全部\n";
    cout << "char ssr[10]=\"asdqwezxc\";\ne.assign(ssr);\ncout<<ssr<<endl;\n";
    char ssr[10] = "asdqwezxc";
    e.assign(ssr);
    cout << ssr << endl
         << endl;

    cout << "4.某字符串char型 前num个\n";
    cout << "e.assign(ssr,4);\ncout<<e<<endl;\n";
    e.assign(ssr, 4);
    cout << e << endl
         << endl;

    cout << "5.某字符赋值\n";
    cout << "赋值3个6\n";
    e.assign(3, '6');
    cout << e << endl
         << endl;

    cout << "copy() 将d中的2位置开始的12个字符覆盖到char型数组ss上\n 必须为-> char型 <-否则报错";
    cout << " char ss[10]=\"123\";\n string dd;\nd.copy(ss,12,2);\ncout<<ss<<endl;\n";
    char ss[15] = "123";
    string dd("abcdefghijklmn");
    dd.copy(ss, 12, 2);
    cout << ss << endl
         << endl;

    return 0;
}